#pragma once
#include <osg/Geometry>
#include <osg/ref_ptr>
#include "MeshData.h"
class RoadMesh :public MeshGroup
{
public:
	RoadMesh();
	void UpDateMesh(double texdensity, double dHeight);

	void LoadFromData(const vector<list<PolyPnt>> vPolyData, double width);

	void LoadFromDimine(string strRoadName, Point_3 pntase, double width);

	void LoadFromOsg(string strRoadName, Point_3 pntase, double width);

	void LoadFromNode(osg::ref_ptr<osg::Node> pNode, Point_3 pntase, double width, double texdensity, double dHeight = 0);

	virtual void SaveData(CFileSaveData& fp);
	virtual void LoadData(CFileLoadData& fp);
protected:
	MeshData CreateRoadMeshWithBottomInx(const vector<Point_3>& vPntBottom, const vector<int>& vInx, const vector<double>& vLengthPolyon, double texdensity, double dHeight = 0);
	
	MeshData CreateRoadMeshWithSimple(const pair<vector<Point_3>, vector<Point_3>>& vPairPnt, const pair <vector<int>, vector<int>>& vPairPntInx, const vector<double>& vLength, double texdensity, double dHeight = 0);
	
	MeshData CreateRoadMeshWithOptimal(const pair<vector<Point_3>, vector<Point_3>>& vPairPnt, const pair <vector<int>, vector<int>>& vPairPntInx, const vector<double>& vLength, double texdensity, double dHeight = 0);
	
	MeshData CreateWithPnt(const vector<Point_3>& vPntGeo, double width, double texdensity, double dHeight = 0);
	
	MeshData CreateWithBottomPnt(const vector<Point_3>& vPntGeo, const vector<double>& vPntProjLength,double texdensity, double dHeight = 0);
	
	vector<MeshData> CreateGroup(osg::ref_ptr<osg::Node> pNode, Point_3 pntase, double width, double texdensity, double dHeight = 0);
	
	MeshData CreateWithOsg(osg::ref_ptr<osg::Geometry> pGeo, Point_3 pntase, double width, double texdensity, double dHeight = 0);
	
	vector<pair<Point_3, Point_3>> CreateRoadBottomPolyonPnt(const vector<Point_3>& vPntGeo, double width);

protected:
	double m_texdensity = 1, m_dHeight = 0;
	vector<vector<Point_3>> m_vMeshPntSide;
	vector<vector<double>> m_vMeshPntLength;
};

